import Vue from 'vue'
import App from './App.vue'
import './registerServiceWorker'
import router from './router'
import store from './store'
// UIku
import '@/ElementUI/index.js'
// 全局样式表
import '@/assets/css/global.css'
// 字体图标
import '@/assets/font/iconfont.css'

// 全局路由守卫
router.beforeEach((to, from, next) => {
  // 用户登录页直接放行
  if (to.path === '/login') {
    return next()
  } else {
    // 判断有没有token
    const tokenStr = sessionStorage.getItem('token')
    if (!tokenStr) return next('/login')
    next()
  }
})
Vue.config.productionTip = false

new Vue({
  router,
  store,
  render: (h) => h(App),
}).$mount('#app')
